<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>请假信息管理系统</title>
    <link rel="stylesheet" href="../../css/register.css">
</head>
<body>
    <div class="bodyBox">
        <img src="../../images/登录左侧.png" alt="" class="picture">
        <form class="loginBox" th:action="@{/login/register}" id="loginBox">
            <h1>请假信息管理系统</h1>
            <div class="inputBox">
                <img src="../../images/登录.png" alt="">
                <input type="text" name="username" placeholder="用户名" id="username">
            </div>
            <div class="inputBox">
                <img src="../../images/密码（关）.png" alt="">
                <input type="password" name="password" placeholder="密码" id="password">
            </div>
            <div class="buttonBox">
                <input type="button" value="注册" onclick="register()">
            </div>
            <label class="annotation">
                <p>注：注册功能仅支持学生注册！！！</p>
            </label>
        </form>
    </div> 
</body>
<script th:inline="javascript">
    function register(){
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        if(username == null) {
            alert("用户名不能为空");
            return false;
        } else if (username.length > 30){
            alert("用户名过长，不能超过30个字符");
            return false;
        }
        if(password == null){
            alert("密码不能为空");
            return false;
        } else if(password.length > 50) {
            alert("密码设置过长");
            return false;
        }
        document.getElementById("loginBox").submit();
    }

    var message = [[${resultInfo?.message}]];
    var code = [[${resultInfo?.code}]];
    console.log(message);
    console.log(code);
    if(code != 20020 && code != null) {
        alert(message);
    }
</script>
</html>